tools/libxc: preserve errno in ERROR and DRINTF macros
authorOlaf Hering <olaf@aepfle.de>
Tue, 11 Mar 2014 09:30:49 +0000 (10:30 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 11 Mar 2014 11:37:06 +0000 (11:37 +0000)
This simplifies a changes made in a follow-up patch.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxc/xc_private.h

index a610f0cef69d2477857702e7aceba081e1c59613..bd2eb86b07195bdb2b97c8d3db58ac199c502470 100644 (file)
@@ -119,13 +119,28 @@ void xc_report_progress_step(xc_interface *xch,
 
 /* anamorphic macros:  struct xc_interface *xch  must be in scope */
 
-#define IPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_INFO,0, _f , ## _a)
-#define DPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DETAIL,0, _f , ## _a)
-#define DBGPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DEBUG,0, _f , ## _a)
-
-#define ERROR(_m, _a...)  xc_report_error(xch,XC_INTERNAL_ERROR,_m , ## _a )
-#define PERROR(_m, _a...) xc_report_error(xch,XC_INTERNAL_ERROR,_m \
-                  " (%d = %s)", ## _a , errno, xc_strerror(xch, errno))
+#define IPRINTF(_f, _a...)  do { int IPRINTF_errno = errno; \
+        xc_report(xch, xch->error_handler, XTL_INFO,0, _f , ## _a); \
+        errno = IPRINTF_errno; \
+        } while (0)
+#define DPRINTF(_f, _a...) do { int DPRINTF_errno = errno; \
+        xc_report(xch, xch->error_handler, XTL_DETAIL,0, _f , ## _a); \
+        errno = DPRINTF_errno; \
+        } while (0)
+#define DBGPRINTF(_f, _a...)  do { int DBGPRINTF_errno = errno; \
+        xc_report(xch, xch->error_handler, XTL_DEBUG,0, _f , ## _a); \
+        errno = DBGPRINTF_errno; \
+        } while (0)
+
+#define ERROR(_m, _a...)  do { int ERROR_errno = errno; \
+        xc_report_error(xch,XC_INTERNAL_ERROR,_m , ## _a ); \
+        errno = ERROR_errno; \
+        } while (0)
+#define PERROR(_m, _a...) do { int PERROR_errno = errno; \
+        xc_report_error(xch,XC_INTERNAL_ERROR,_m " (%d = %s)", \
+        ## _a , errno, xc_strerror(xch, errno)); \
+        errno = PERROR_errno; \
+        } while (0)
 
 /*
  * HYPERCALL ARGUMENT BUFFERS